const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        user: {},
        no_vip:false
    },
    
     //首页
   goindex: function(e) {
    wx.redirectTo({
        url: '/pages/index/index'
    })
},
   //我的订单
   myorder: function() {
    wx.redirectTo({
        url: '/pages/my_order/my_order'
    })
},
// 关于我们
company_intr: function () {
    wx.navigateTo({
        url: '/pages/company_intr/company_intr'
    })
},
//我的
my: function() {
    wx.redirectTo({
        url: '/pages/my/my'
    })
},
//申请入驻
join_seller: function() {
    wx.navigateTo({
        url: '/pages/join/join'
    })
},
    account_chongzhi: function () {
        wx.navigateTo({
            url: '/pages/account_chongzhi/account_chongzhi',
        })
    },
    vip_explain: function () {
        wx.navigateTo({
            url: '/pages/user_set/user_set',
        })
    },
    my_cardbag: function () {
        wx.navigateTo({
            url: '/pages/my_cardbag/my_cardbag',
        })
    },
    my_wallet: function () {
        wx.navigateTo({
            url: '/pages/my_wallet/my_wallet',
        })
    },
    // 会员中心
    my_member: function () {
        // wx.navigateTo({
        //     url: '/pages/my_member/my_member',
        // })
    },
    my_order: function () {
        wx.navigateTo({
            url: '/pages/my_order/my_order',
        })
    },
    my_jifen: function () {
        wx.navigateTo({
            url: '/pages/jifen_mingxi/jifen_mingxi',
        })
    },
    //优惠卷
    coupon: function () {
        wx.navigateTo({
            url: '/pages/coupon/coupon',
        })
    },
    //团购卷
    tg_coupon: function () {
      wx.navigateTo({
          url: '/pages/tg_coupon/tg_coupon',
      })
  },
    callPhone: function(e) {
        var tel = wx.getStorageSync('tel');
        if(tel)
        wx.makePhoneCall({
            phoneNumber: tel,
            success: function () {},
        })
    },
    youhui_chongzhi: function () {
        wx.navigateTo({
            url: '/pages/youhui_chongzhi/youhui_chongzhi',
        })
    },
    my_address: function () {
        wx.navigateTo({
            url: '/pages/add_address/add_address'
        })
    },
    my_staff:function () {
        wx.navigateTo({
            url: '/pages/my_staff/my_staff',
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    userinfo: function () {
        app.ajax({
            url: '/api/user/userinfo',
            success: res => {
                if (res.code == 1) {
                    wx.setStorageSync('user', res.data);
                    var is_vip = false
                    if(res.data.vip == 0)   is_vip = false
                    else  is_vip = true
                    this.setData({
                        user: res.data,
                        // no_vip: is_vip
                        no_vip: true
                        
                    })
                }
            }
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        this.userinfo();
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})